﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.SweptVolume.CuiSvMultipleOpSweptVolumeDlg
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;
using UiInternalControls;


namespace DnProcessSimulateCommands.SweptVolume;

public class CuiSvMultipleOpSweptVolumeDlg : TxForm
{
  private IContainer components;
  internal const string SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_ACCURACY = "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_ACCURACY";
  private const string SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_CLEARANCE = "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_CLEARANCE";
  private const string SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_RESET = "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_RESET";
  private const string SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_INCLUDE_CABLES = "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_INCLUDE_CABLES";
  private const bool CREATE_MODE = false;
  private const bool STOP_MODE = true;
  private const int CLEARANCE_UPPER_LIMIT_MM = 5000;
  private const int ACCURACY_THRESHOLD = 10;
  private Button m_create_button;
  private Button m_close_button;
  private Label m_fast_label;
  private Label m_accurate_label;
  private TxProgressBar m_progressBar;
  private Label m_maxError_label;
  private Label m_accuracyValue_label;
  private Label m_clearance_label;
  private NumericUpDown m_clearance_numericUpDown;
  private CCoSVSweptVolumeCmd m_cmd;
  private CApSVSweptVolume m_application;
  private TxObjGridCtrl m_operations_txObjGridCtrl;
  private CApSVHoldingObjectValidator m_svhValidator;
  private bool m_createOrStopMode;
  private TxSweptVolume_MayProceedCalculation m_mayProceedCallBack;
  private CheckBox m_reset_checkBox;
  private TxButton m_up_button;
  private TxButton m_down_button;
  private bool m_shouldStop;
  private TxSimulationSnapshotDataEx m_simulationSnapshotData;
  private Dictionary<string, ITxLocatableObject> m_gridObjIdToRegRootObjectMap;
  private GroupBox groupBox1;
  private Label m_accuracyUnits_label;
  private CheckBox m_checkBox_IncludeCable;
  private TxInfoButton txToolTipWarningAccuracy;
  private TxTrackBar m_accuracy_trackBar;
  private List<ITxSweptVolumeHoldingObject> m_gridObjectsWithRootsObjectsDeletedDuringSimulation;

  public CuiSvMultipleOpSweptVolumeDlg(CCoSVSweptVolumeCmd cmd)
  {
    this.InitializeComponent();
    this.m_cmd = cmd;
    this.m_createOrStopMode = false;
    // ISSUE: method pointer
    this.m_mayProceedCallBack = new TxSweptVolume_MayProceedCalculation((object) this, __methodptr(mayProceed));
    this.m_shouldStop = false;
    this.m_svhValidator = new CApSVHoldingObjectValidator(true);
    bool isTcAnyPlatform = TxTcUtilities.IsTcAnyPlatform;
    this.m_svhValidator.AllowObjectFlowOperations = true;
    this.m_svhValidator.AllowRoboticOperations = true;
    this.m_svhValidator.AllowRoboticPrograms = !isTcAnyPlatform;
    this.m_up_button.SetImage(TxImageManager.GetImageByKey("ArrowUp"), new Size());
    this.m_down_button.SetImage(TxImageManager.GetImageByKey("ArrowDown"), new Size());
    cmd.DialogIsOpen(true);
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CuiSvMultipleOpSweptVolumeDlg));
    this.m_create_button = new Button();
    this.m_close_button = new Button();
    this.m_fast_label = new Label();
    this.m_accurate_label = new Label();
    this.m_progressBar = new TxProgressBar();
    this.m_maxError_label = new Label();
    this.m_accuracyValue_label = new Label();
    this.m_operations_txObjGridCtrl = new TxObjGridCtrl();
    this.m_clearance_label = new Label();
    this.m_clearance_numericUpDown = new NumericUpDown();
    this.m_reset_checkBox = new CheckBox();
    this.m_up_button = new TxButton();
    this.m_down_button = new TxButton();
    this.groupBox1 = new GroupBox();
    this.txToolTipWarningAccuracy = new TxInfoButton();
    this.m_accuracyUnits_label = new Label();
    this.m_checkBox_IncludeCable = new CheckBox();
    this.m_accuracy_trackBar = new TxTrackBar();
    this.m_clearance_numericUpDown.BeginInit();
    this.groupBox1.SuspendLayout();
    ((ISupportInitialize) this.m_accuracy_trackBar).BeginInit();
    ((Control) this).SuspendLayout();
    this.m_create_button.DialogResult = DialogResult.Cancel;
    componentResourceManager.ApplyResources((object) this.m_create_button, "m_create_button");
    this.m_create_button.Name = "m_create_button";
    this.m_create_button.Click += new EventHandler(this.m_create_button_Click);
    this.m_close_button.DialogResult = DialogResult.Cancel;
    componentResourceManager.ApplyResources((object) this.m_close_button, "m_close_button");
    this.m_close_button.Name = "m_close_button";
    this.m_close_button.Click += new EventHandler(this.m_close_button_Click);
    componentResourceManager.ApplyResources((object) this.m_fast_label, "m_fast_label");
    this.m_fast_label.Name = "m_fast_label";
    componentResourceManager.ApplyResources((object) this.m_accurate_label, "m_accurate_label");
    this.m_accurate_label.Name = "m_accurate_label";
    componentResourceManager.ApplyResources((object) this.m_progressBar, "m_progressBar");
    ((Control) this.m_progressBar).Name = "m_progressBar";
    ((ProgressBar) this.m_progressBar).Step = 1;
    componentResourceManager.ApplyResources((object) this.m_maxError_label, "m_maxError_label");
    this.m_maxError_label.BackColor = SystemColors.Control;
    this.m_maxError_label.Name = "m_maxError_label";
    componentResourceManager.ApplyResources((object) this.m_accuracyValue_label, "m_accuracyValue_label");
    this.m_accuracyValue_label.Name = "m_accuracyValue_label";
    componentResourceManager.ApplyResources((object) this.m_operations_txObjGridCtrl, "m_operations_txObjGridCtrl");
    ((UserControl) this.m_operations_txObjGridCtrl).BorderStyle = BorderStyle.FixedSingle;
    this.m_operations_txObjGridCtrl.ChangeGeneralSelection = false;
    this.m_operations_txObjGridCtrl.CurrentRow = -1;
    this.m_operations_txObjGridCtrl.EnableMultipleSelection = true;
    this.m_operations_txObjGridCtrl.EnableRecurringObjects = false;
    this.m_operations_txObjGridCtrl.ListenToPick = false;
    ((Control) this.m_operations_txObjGridCtrl).Name = "m_operations_txObjGridCtrl";
    this.m_operations_txObjGridCtrl.PickLevel = (TxPickLevel) 1;
    this.m_operations_txObjGridCtrl.ReadOnly = false;
    this.m_operations_txObjGridCtrl.ValidatorType = (TxValidatorType) 10;
    this.m_operations_txObjGridCtrl.ObjectDeleting += new TxObjGridCtrl_ObjectDeletingEventHandler(this.m_operations_txObjGridCtrl_ControlDeleted);
    this.m_operations_txObjGridCtrl.ObjectInserted += new TxObjGridCtrl_ObjectInsertedEventHandler(this.m_operations_txObjGridCtrl_ObjectInserted);
    this.m_operations_txObjGridCtrl.Picked += new TxObjGridCtrl_PickedEventHandler(this.m_operations_txObjGridCtrl_Picked);
    this.m_operations_txObjGridCtrl.RowDeleted += new TxObjGridCtrl_RowDeletedEventHandler(this.m_operations_txObjGridCtrl_RowDeleted);
    this.m_operations_txObjGridCtrl.InvalidObjectTyped += new TxObjGridCtrl_InvalidObjectTypedEventHandler(this.m_operations_txObjGridCtrl_InvalidObjectTyped);
    this.m_operations_txObjGridCtrl.ValidObjectTyped += new TxObjGridCtrl_ValidObjectTypedEventHandler(this.m_operations_txObjGridCtrl_ValidObjectTyped);
    this.m_operations_txObjGridCtrl.SelectionChanged += new TxObjGridCtrl_SelectionChangedEventHandler(this.m_operations_txObjGridCtrl_SelectionChanged);
    componentResourceManager.ApplyResources((object) this.m_clearance_label, "m_clearance_label");
    this.m_clearance_label.Name = "m_clearance_label";
    this.m_clearance_numericUpDown.DecimalPlaces = 2;
    this.m_clearance_numericUpDown.Increment = new Decimal(new int[4]
    {
      10,
      0,
      0,
      0
    });
    componentResourceManager.ApplyResources((object) this.m_clearance_numericUpDown, "m_clearance_numericUpDown");
    this.m_clearance_numericUpDown.Maximum = new Decimal(new int[4]
    {
      1000000000,
      0,
      0,
      0
    });
    this.m_clearance_numericUpDown.Name = "m_clearance_numericUpDown";
    componentResourceManager.ApplyResources((object) this.m_reset_checkBox, "m_reset_checkBox");
    this.m_reset_checkBox.Checked = true;
    this.m_reset_checkBox.CheckState = CheckState.Checked;
    this.m_reset_checkBox.Name = "m_reset_checkBox";
    this.m_reset_checkBox.UseVisualStyleBackColor = true;
    componentResourceManager.ApplyResources((object) this.m_up_button, "m_up_button");
    ((Control) this.m_up_button).Name = "m_up_button";
    ((ButtonBase) this.m_up_button).UseVisualStyleBackColor = true;
    ((Control) this.m_up_button).Click += new EventHandler(this.m_up_button_Click);
    componentResourceManager.ApplyResources((object) this.m_down_button, "m_down_button");
    ((Control) this.m_down_button).Name = "m_down_button";
    ((ButtonBase) this.m_down_button).UseVisualStyleBackColor = true;
    ((Control) this.m_down_button).Click += new EventHandler(this.m_down_button_Click);
    componentResourceManager.ApplyResources((object) this.groupBox1, "groupBox1");
    this.groupBox1.Controls.Add((Control) this.m_accuracy_trackBar);
    this.groupBox1.Controls.Add((Control) this.txToolTipWarningAccuracy);
    this.groupBox1.Controls.Add((Control) this.m_accuracyUnits_label);
    this.groupBox1.Controls.Add((Control) this.m_maxError_label);
    this.groupBox1.Controls.Add((Control) this.m_accuracyValue_label);
    this.groupBox1.Controls.Add((Control) this.m_accurate_label);
    this.groupBox1.Controls.Add((Control) this.m_fast_label);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.TabStop = false;
    componentResourceManager.ApplyResources((object) this.txToolTipWarningAccuracy, "txToolTipWarningAccuracy");
    ((Control) this.txToolTipWarningAccuracy).Name = "txToolTipWarningAccuracy";
    this.txToolTipWarningAccuracy.TabStop = true;
    this.txToolTipWarningAccuracy.TooltipDuration = 5000;
    this.txToolTipWarningAccuracy.TooltipText = (string) null;
    this.txToolTipWarningAccuracy.TooltipTitle = "";
    this.txToolTipWarningAccuracy.Type = (TxInfoButton.InfoType) 0;
    componentResourceManager.ApplyResources((object) this.m_accuracyUnits_label, "m_accuracyUnits_label");
    this.m_accuracyUnits_label.BackColor = SystemColors.Control;
    this.m_accuracyUnits_label.Name = "m_accuracyUnits_label";
    componentResourceManager.ApplyResources((object) this.m_checkBox_IncludeCable, "m_checkBox_IncludeCable");
    this.m_checkBox_IncludeCable.Checked = true;
    this.m_checkBox_IncludeCable.CheckState = CheckState.Checked;
    this.m_checkBox_IncludeCable.Name = "m_checkBox_IncludeCable";
    this.m_checkBox_IncludeCable.UseVisualStyleBackColor = true;
    this.m_checkBox_IncludeCable.CheckedChanged += new EventHandler(this.m_checkBox_IncludeCable_CheckedChanged);
    componentResourceManager.ApplyResources((object) this.m_accuracy_trackBar, "m_accuracy_trackBar");
    ((TrackBar) this.m_accuracy_trackBar).Maximum = 100;
    ((Control) this.m_accuracy_trackBar).Name = "m_accuracy_trackBar";
    ((TrackBar) this.m_accuracy_trackBar).TickFrequency = 10;
    ((TrackBar) this.m_accuracy_trackBar).Value = 30;
    ((TrackBar) this.m_accuracy_trackBar).ValueChanged += new EventHandler(this.m_accuracy_trackBar_ValueChanged);
    ((Form) this).AcceptButton = (IButtonControl) this.m_create_button;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((Form) this).CancelButton = (IButtonControl) this.m_close_button;
    ((Control) this).Controls.Add((Control) this.m_checkBox_IncludeCable);
    ((Control) this).Controls.Add((Control) this.groupBox1);
    ((Control) this).Controls.Add((Control) this.m_down_button);
    ((Control) this).Controls.Add((Control) this.m_up_button);
    ((Control) this).Controls.Add((Control) this.m_reset_checkBox);
    ((Control) this).Controls.Add((Control) this.m_clearance_numericUpDown);
    ((Control) this).Controls.Add((Control) this.m_clearance_label);
    ((Control) this).Controls.Add((Control) this.m_operations_txObjGridCtrl);
    ((Control) this).Controls.Add((Control) this.m_progressBar);
    ((Control) this).Controls.Add((Control) this.m_create_button);
    ((Control) this).Controls.Add((Control) this.m_close_button);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CuiSvMultipleOpSweptVolumeDlg);
    ((Form) this).Closing += new CancelEventHandler(this.CuiSvMultipleOpSweptVolumeDlg_Closing);
    ((Form) this).Closed += new EventHandler(this.CuiSvMultipleOpSweptVolumeDlg_Closed);
    ((Form) this).FormClosing += new FormClosingEventHandler(this.CuiSvMultipleOpSweptVolumeDlg_FormClosing);
    this.m_clearance_numericUpDown.EndInit();
    this.groupBox1.ResumeLayout(false);
    this.groupBox1.PerformLayout();
    ((ISupportInitialize) this.m_accuracy_trackBar).EndInit();
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }

  public virtual void OnInitTxForm()
  {
    if (TxApplication.ActiveDocument.SimulationPlayer.IsSimulationRunning())
      this.m_create_button.Enabled = false;
    else
      this.m_create_button.Enabled = true;
    TxApplication.ActiveDocument.SimulationPlayer.SimulationStartedForward += new TxSimulationPlayer_SimulationStartedForwardEventHandler(this.SimulationPlayer_SimulationStartedForward);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationStartedBackward += new TxSimulationPlayer_SimulationStartedBackwardEventHandler(this.SimulationPlayer_SimulationStartedBackward);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationStopped += new TxSimulationPlayer_SimulationStoppedEventHandler(this.SimulationPlayer_SimulationStopped);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationEndedBackward += new TxSimulationPlayer_SimulationEndedBackwardEventHandler(this.SimulationPlayer_SimulationEndedBackward);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationEndedForward += new TxSimulationPlayer_SimulationEndedForwardEventHandler(this.SimulationPlayer_SimulationEndedForward);
    this.initOpList();
    this.initAccuracyTrackBar();
    this.UpdateAccuracyValue();
    this.initClearance();
    this.enableCreateIfValid();
    this.initResetBetweenItems();
    this.initIncludeCables();
  }

  private void initOpList()
  {
    // ISSUE: unable to decompile the method.
  }

  private void initAccuracyTrackBar()
  {
    object s = (object) null;
    TxFormSettings.RestoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_ACCURACY", ref s);
    if (s != null)
    {
      try
      {
        ((TrackBar) this.m_accuracy_trackBar).Value = int.Parse(s as string);
      }
      catch (Exception ex)
      {
      }
    }
    this.m_accuracyUnits_label.Text = TxApplication.Options.Units.LinearUnitName;
    this.txToolTipWarningAccuracy.TooltipDuration = 10000;
    this.txToolTipWarningAccuracy.TooltipText = StringTable.SV_ACCURACY_VALUE_WARNING_TOOLTIP;
    this.txToolTipWarningAccuracy.Type = (TxInfoButton.InfoType) 1;
    ((Control) this.txToolTipWarningAccuracy).Visible = false;
  }

  private void initClearance()
  {
    object s = (object) null;
    TxFormSettings.RestoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_CLEARANCE", ref s);
    if (s == null)
      return;
    try
    {
      Decimal num1 = Decimal.Parse(s as string);
      double linearMultiplier = TxApplication.Options.Units.LinearMultiplier;
      Decimal num2 = num1 / (Decimal) linearMultiplier;
      this.m_clearance_numericUpDown.Maximum = 5000M / (Decimal) linearMultiplier;
      this.m_clearance_numericUpDown.Value = num2;
    }
    catch (Exception ex)
    {
    }
  }

  private void initResetBetweenItems()
  {
    this.m_reset_checkBox.Checked = false;
    object obj = (object) null;
    TxFormSettings.RestoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_RESET", ref obj);
    if (obj == null)
      return;
    if (obj.ToString().ToLower() == "true")
      this.m_reset_checkBox.Checked = true;
    else
      this.m_reset_checkBox.Checked = false;
  }

  private void initIncludeCables()
  {
    this.m_checkBox_IncludeCable.Checked = false;
    object obj;
    TxFormSettings.RestoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_INCLUDE_CABLES", ref obj);
    if (obj == null)
      return;
    if (obj.ToString().ToLower() == "true")
      this.m_checkBox_IncludeCable.Checked = true;
    else
      this.m_checkBox_IncludeCable.Checked = false;
  }

  private void formatAccuracyValue()
  {
    string linearUnitName = TxApplication.Options.Units.LinearUnitName;
    this.m_accuracyValue_label.Text = $"{Math.Round((double) ((TrackBar) this.m_accuracy_trackBar).Value / TxApplication.Options.Units.LinearMultiplier, Math.Min(TxApplication.Options.Units.LinearDigitsAfterDecimalPoint, 2)).ToString()} {linearUnitName}";
  }

  private string FormatLinearValue(double value)
  {
    double linearMultiplier = TxApplication.Options.Units.LinearMultiplier;
    int digits = Math.Min(TxApplication.Options.Units.LinearDigitsAfterDecimalPoint, 2);
    return Math.Round(value / linearMultiplier, digits).ToString();
  }

  private void UpdateAccuracyValue()
  {
    int num = ((TrackBar) this.m_accuracy_trackBar).Value;
    this.m_accuracyValue_label.Text = this.FormatLinearValue((double) num);
    Label accuracyUnitsLabel = this.m_accuracyUnits_label;
    Point location = this.m_accuracyValue_label.Location;
    int x = location.X + this.m_accuracyValue_label.Width;
    location = this.m_accuracyUnits_label.Location;
    int y = location.Y;
    Point point = new Point(x, y);
    accuracyUnitsLabel.Location = point;
    if (num < 10)
    {
      ((Control) this.txToolTipWarningAccuracy).Visible = true;
      ((Control) this.m_accuracy_trackBar).BackColor = Color.Yellow;
      this.m_accuracyValue_label.BackColor = Color.Yellow;
    }
    else
    {
      ((Control) this.txToolTipWarningAccuracy).Visible = false;
      ((Control) this.m_accuracy_trackBar).BackColor = Color.FromKnownColor(KnownColor.Control);
      this.m_accuracyValue_label.BackColor = Color.FromKnownColor(KnownColor.Control);
    }
  }

  private void m_operations_txObjGridCtrl_ControlAdded(
    object sender,
    TxObjGridCtrl_ObjectInsertedEventArgs args)
  {
    if (this.m_operations_txObjGridCtrl.Count > 1)
    {
      ((Control) this.m_down_button).Enabled = true;
      ((Control) this.m_up_button).Enabled = true;
    }
    else
    {
      ((Control) this.m_down_button).Enabled = false;
      ((Control) this.m_up_button).Enabled = false;
    }
  }

  private void m_operations_txObjGridCtrl_ControlDeleted(
    object sender,
    TxObjGridCtrl_ObjectDeletingEventArgs args)
  {
    if (args.Obj is ITxSweptVolumeHoldingObject)
      this.unregisterForRootObjectEvents(args.Obj as ITxSweptVolumeHoldingObject);
    if (this.m_operations_txObjGridCtrl.Count > 1)
    {
      ((Control) this.m_down_button).Enabled = true;
      ((Control) this.m_up_button).Enabled = true;
    }
    else
    {
      ((Control) this.m_down_button).Enabled = false;
      ((Control) this.m_up_button).Enabled = false;
    }
    this.enableCreateIfValid();
  }

  private void addObjToListIfValid(ITxObject obj)
  {
    if (this.m_svhValidator.IsValidObject(obj, out string _) && !((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects).Contains(obj))
      this.m_operations_txObjGridCtrl.AppendObject(obj);
    if (!(obj is ITxObjectCollection))
      return;
    foreach (ITxObject directDescendant in (Collection<ITxObject>) (obj as ITxObjectCollection).GetDirectDescendants((ITxTypeFilter) new TxTypeFilter(typeof (ITxCompoundOperation))))
      this.addObjToListIfValid(directDescendant);
  }

  private void enableCreateIfValid()
  {
    bool flag = false;
    if (this.m_operations_txObjGridCtrl.Count > 0)
    {
      flag = true;
      foreach (ITxObject itxObject in (Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)
      {
        if (itxObject == null)
          flag = false;
      }
    }
    if (TxApplication.ActiveDocument.SimulationPlayer.IsSimulationRunning())
      return;
    this.m_create_button.Enabled = flag;
  }

  private void abortSweptVolumeCreation()
  {
    ((Control) this).Enabled = false;
    this.m_create_button.Enabled = false;
    this.m_application.abort();
    this.m_application = (CApSVSweptVolume) null;
    this.endSweptVolumeCreation();
    ((Control) this).Enabled = true;
  }

  private bool mayCreateSweptVolumesForOperations()
  {
    bool volumesForOperations = true;
    bool flag = false;
    TxObjectList objects = this.m_operations_txObjGridCtrl.Objects;
    double clearanceInMm = (double) this.getClearanceInMM();
    for (int index = 0; index < ((Collection<ITxObject>) objects).Count && !flag; ++index)
      flag = TxSweptVolume.op_Inequality(CApSVSweptVolume.getSVWithClearanceType(((Collection<ITxObject>) objects)[index] as ITxSweptVolumeHoldingObject, clearanceInMm), (ITxObject) null);
    if (flag)
    {
      volumesForOperations = false;
      ResourceManager resourceManager = new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly);
      resourceManager.GetString("SV_NAME");
      string str = "Unknown Error";
      str = resourceManager.GetString("SV_CONFIRM_OVERWRITE_OF_OPERATION_SV");
      if (this.reportError(EApSweptVolumeErrorType.SV_CONFIRM_OVERWRITE_OF_OPERATION_SV) == DialogResult.Yes)
        volumesForOperations = true;
    }
    return volumesForOperations;
  }

  private DialogResult reportError(EApSweptVolumeErrorType errorCode, params object[] errorParams)
  {
    ResourceManager resourceManager = new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly);
    string str1 = resourceManager.GetString("SV_NAME");
    string str2 = "Unknown Error";
    MessageBoxButtons messageBoxButtons = MessageBoxButtons.OK;
    MessageBoxIcon messageBoxIcon = MessageBoxIcon.None;
    if (errorCode == EApSweptVolumeErrorType.SV_CONFIRM_OVERWRITE_OF_OPERATION_SV)
    {
      string str3 = resourceManager.GetString("SV_CONFIRM_OVERWRITE_OF_OBJECT_SV_PART_1") + " ";
      str2 = $"{(!(this.getClearanceInMM() == 0M) ? str3 + resourceManager.GetString("SV_CONFIRM_OVERWRITE_OF_OBJECT_SV_WITH") : str3 + resourceManager.GetString("SV_CONFIRM_OVERWRITE_OF_OBJECT_SV_WITHOUT"))} {resourceManager.GetString("SV_CONFIRM_OVERWRITE_OF_OBJECT_SV_PART_2")}";
      messageBoxButtons = MessageBoxButtons.YesNo;
      messageBoxIcon = MessageBoxIcon.Question;
    }
    if (errorCode == EApSweptVolumeErrorType.SV_UNABLE_TO_CREATE_SWEPT_VOLUME)
    {
      str2 = resourceManager.GetString("SV_UNABLE_TO_CREATE_SWEPT_VOLUME");
      messageBoxButtons = MessageBoxButtons.OK;
      messageBoxIcon = MessageBoxIcon.Hand;
    }
    if (errorCode == EApSweptVolumeErrorType.SV_MISSING_OPERATION_SIMULATED_OBJECT_BEFORE_CREATE)
    {
      if (errorParams.Length == 1)
        str2 = string.Format(resourceManager.GetString("SV_MISSING_OPERATION_SIMULATED_OBJECT_BEFORE_CREATE"), (object) ((ITxObject) (errorParams[0] as ITxOperation)).Name);
      else if (errorParams.Length > 1)
      {
        string empty = string.Empty;
        for (int index = 0; index < errorParams.Length; ++index)
        {
          if (index > 0)
            empty += ", ";
          empty += (errorParams[index] as ITxObject).Name;
        }
        str2 = string.Format(resourceManager.GetString("SV_MISSING_OPERATIONS_SIMULATED_OBJECT_BEFORE_CREATE"), (object) empty);
      }
      messageBoxButtons = MessageBoxButtons.OK;
      messageBoxIcon = MessageBoxIcon.Hand;
    }
    else if (errorCode == EApSweptVolumeErrorType.SV_MISSING_OPERATION_SIMULATED_OBJECT_DURING_CREATE)
    {
      if (errorParams.Length == 1)
        str2 = string.Format(resourceManager.GetString("SV_MISSING_OPERATION_SIMULATED_OBJECT_DURING_CREATE"), (object) ((ITxObject) (errorParams[0] as ITxOperation)).Name);
      else if (errorParams.Length > 1)
      {
        string empty = string.Empty;
        for (int index = 0; index < errorParams.Length; ++index)
        {
          if (index > 0)
            empty += ", ";
          empty += (errorParams[index] as ITxObject).Name;
        }
        str2 = string.Format(resourceManager.GetString("SV_MISSING_OPERATIONS_SIMULATED_OBJECT_DURING_CREATE"), (object) empty);
      }
      messageBoxButtons = MessageBoxButtons.OK;
      messageBoxIcon = MessageBoxIcon.Hand;
    }
    return TxMessageBox.Show(str2, str1, messageBoxButtons, messageBoxIcon);
  }

  private void createSweptVolumes()
  {
    this.startSweptVolumeCreation();
    this.m_simulationSnapshotData = (TxSimulationSnapshotDataEx) null;
    TxObjectList objects = this.m_operations_txObjGridCtrl.Objects;
    for (int index = 0; index < ((Collection<ITxObject>) objects).Count && !this.m_shouldStop; ++index)
    {
      if (((Collection<ITxObject>) objects)[index] is ITxSweptVolumeHoldingObject volumeHoldingObject)
      {
        if (CApSVUtilities.getRootObject(volumeHoldingObject) != null)
        {
          if (!this.isRegisteredForRootObjectEvents(volumeHoldingObject))
            this.registerForRootObjectEvents(volumeHoldingObject);
          this.m_application = new CApSVSweptVolume(volumeHoldingObject);
          this.m_application.CallBack = this.m_mayProceedCallBack;
          if (index == 0)
            this.m_application.SimulationInitialized += new CApSimulationHandler_SimulationInitializedEventHandler(this.m_application_SimulationInitialized);
          ((ProgressBar) this.m_progressBar).PerformStep();
          this.m_application.Rewind = index == ((Collection<ITxObject>) objects).Count - 1 || this.m_reset_checkBox.Checked;
          this.m_operations_txObjGridCtrl.SetCurrentCell(index, 0);
          ((Control) this.m_up_button).Enabled = false;
          ((Control) this.m_down_button).Enabled = false;
          this.m_application.createSweptVolume((double) ((TrackBar) this.m_accuracy_trackBar).Value, (double) this.getClearanceInMM(), this.m_checkBox_IncludeCable.Checked);
          ((ProgressBar) this.m_progressBar).Value = ((ProgressBar) this.m_progressBar).Minimum;
        }
        else
        {
          int num = (int) this.reportError(EApSweptVolumeErrorType.SV_MISSING_OPERATION_SIMULATED_OBJECT_DURING_CREATE, (object) volumeHoldingObject);
          this.m_shouldStop = true;
        }
      }
    }
    this.applySimulationSnapshot();
    this.m_simulationSnapshotData = (TxSimulationSnapshotDataEx) null;
    TxApplication.ActiveUndoManager.ClearAllTransactions();
    this.m_application = (CApSVSweptVolume) null;
  }

  private void startSweptVolumeCreation()
  {
    this.m_create_button.Text = StringTable.ResourceManager.GetString("SV_Stop");
    this.m_close_button.Enabled = false;
    ((Control) this.m_operations_txObjGridCtrl).Enabled = false;
    ((Control) this.m_accuracy_trackBar).Enabled = false;
    this.m_clearance_numericUpDown.Enabled = false;
    this.m_reset_checkBox.Enabled = false;
    ((Control) this).Refresh();
  }

  private void endSweptVolumeCreation()
  {
    this.m_create_button.Text = StringTable.ResourceManager.GetString("SV_Create");
    this.m_createOrStopMode = false;
    ((Control) this.m_operations_txObjGridCtrl).Enabled = true;
    ((Control) this.m_accuracy_trackBar).Enabled = true;
    this.m_clearance_numericUpDown.Enabled = true;
    this.m_reset_checkBox.Enabled = true;
    ((ProgressBar) this.m_progressBar).Value = ((ProgressBar) this.m_progressBar).Minimum;
    TxApplication.RefreshDisplay();
  }

  private Decimal getClearanceInMM()
  {
    return this.m_clearance_numericUpDown.Value * (Decimal) TxApplication.Options.Units.LinearMultiplier;
  }

  private bool mayProceed(int progress)
  {
    if (progress >= 0 && progress <= 100 && progress > ((ProgressBar) this.m_progressBar).Value)
      ((ProgressBar) this.m_progressBar).Value = progress;
    this.getUIMessages();
    return !this.m_shouldStop;
  }

  private void getUIMessages() => Application.DoEvents();

  private void CuiSvMultipleOpSweptVolumeDlg_Closing(object sender, CancelEventArgs e)
  {
    if (!this.m_createOrStopMode && this.m_application != null)
      this.abortSweptVolumeCreation();
    TxApplication.RefreshDisplay();
    TxFormSettings.StoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_ACCURACY", (object) ((TrackBar) this.m_accuracy_trackBar).Value.ToString());
    TxFormSettings.StoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_CLEARANCE", (object) this.getClearanceInMM().ToString());
    TxFormSettings.StoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_RESET", (object) this.m_reset_checkBox.Checked.ToString());
    TxFormSettings.StoreFormValue((Form) this, "SWEPT_VOLUME_MULTIPLE_OPERATIONS_DLG_INCLUDE_CABLES", (object) this.m_checkBox_IncludeCable.Checked.ToString());
    if (e.Cancel)
      return;
    this.unregisterForRootObjectEvents();
  }

  private void CuiSvMultipleOpSweptVolumeDlg_Closed(object sender, EventArgs e)
  {
    TxApplication.ActiveDocument.SimulationPlayer.SimulationStartedForward -= new TxSimulationPlayer_SimulationStartedForwardEventHandler(this.SimulationPlayer_SimulationStartedForward);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationStartedBackward -= new TxSimulationPlayer_SimulationStartedBackwardEventHandler(this.SimulationPlayer_SimulationStartedBackward);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationStopped -= new TxSimulationPlayer_SimulationStoppedEventHandler(this.SimulationPlayer_SimulationStopped);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationEndedBackward -= new TxSimulationPlayer_SimulationEndedBackwardEventHandler(this.SimulationPlayer_SimulationEndedBackward);
    TxApplication.ActiveDocument.SimulationPlayer.SimulationEndedForward -= new TxSimulationPlayer_SimulationEndedForwardEventHandler(this.SimulationPlayer_SimulationEndedForward);
    TxApplication.ActiveDocument.SimulationPlayer.ResetToDefaultSetting();
    this.m_cmd.DialogIsOpen(false);
  }

  private void m_close_button_Click(object sender, EventArgs e)
  {
    if (this.m_createOrStopMode)
      return;
    ((Form) this).Close();
  }

  private void m_accuracy_trackBar_ValueChanged(object sender, EventArgs e)
  {
    this.UpdateAccuracyValue();
  }

  private void m_create_button_Click(object sender, EventArgs e)
  {
    if (this.m_createOrStopMode)
    {
      this.m_create_button.Enabled = false;
      this.m_createOrStopMode = !this.m_createOrStopMode;
      this.m_shouldStop = true;
      this.abortSweptVolumeCreation();
      this.RefreshUpDownButtonsStatus();
    }
    else
    {
      if (!this.mayCreateSweptVolumesForOperations())
        return;
      this.m_createOrStopMode = !this.m_createOrStopMode;
      this.m_shouldStop = false;
      try
      {
        this.createSweptVolumes();
      }
      catch (TxSweptVolumeCalculationFailedException ex)
      {
        int num = (int) this.reportError(EApSweptVolumeErrorType.SV_UNABLE_TO_CREATE_SWEPT_VOLUME);
      }
      catch (NullReferenceException ex)
      {
        int num = (int) this.reportError(EApSweptVolumeErrorType.SV_UNABLE_TO_CREATE_SWEPT_VOLUME);
      }
      finally
      {
        this.endSweptVolumeCreation();
        this.m_create_button.Enabled = true;
        this.m_close_button.Enabled = true;
        this.RefreshUpDownButtonsStatus();
        TxApplication.ActiveUndoManager.ClearAllTransactions();
      }
    }
  }

  private void CuiSvMultipleOpSweptVolumeDlg_FormClosing(object sender, FormClosingEventArgs e)
  {
    if (!this.m_createOrStopMode && this.m_close_button.Enabled)
      return;
    e.Cancel = true;
  }

  private void m_operations_txObjGridCtrl_InvalidObjectTyped(
    object sender,
    TxObjGridCtrl_InvalidObjectTypedEventArgs args)
  {
    this.m_create_button.Enabled = false;
  }

  private void m_operations_txObjGridCtrl_ValidObjectTyped(
    object sender,
    TxObjGridCtrl_ValidObjectTypedEventArgs args)
  {
    this.enableCreateIfValid();
  }

  private void m_operations_txObjGridCtrl_Picked(object sender, TxObjGridCtrl_PickedEventArgs args)
  {
    this.addObjToListIfValid(args.Obj);
    this.m_operations_txObjGridCtrl.Focus();
  }

  private void m_operations_txObjGridCtrl_ObjectInserted(
    object sender,
    TxObjGridCtrl_ObjectInsertedEventArgs args)
  {
    if (args.Obj is ITxSweptVolumeHoldingObject)
      this.registerForRootObjectEvents(args.Obj as ITxSweptVolumeHoldingObject);
    this.enableCreateIfValid();
  }

  private void m_up_button_Click(object sender, EventArgs e)
  {
    TxObjectList selectedObjects = this.m_operations_txObjGridCtrl.SelectedObjects;
    foreach (ITxObject itxObject in (Collection<ITxObject>) this.ListOfSelectedObjectsOrdered())
    {
      int row1 = ((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects).IndexOf(itxObject);
      if (row1 > 0)
        this.SwapRows(row1, row1 - 1);
    }
    this.m_operations_txObjGridCtrl.SetCurrentCell(((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects).IndexOf(((Collection<ITxObject>) selectedObjects)[0]), 0);
    this.m_operations_txObjGridCtrl.SelectedObjects = new TxObjectList(selectedObjects);
  }

  private void m_down_button_Click(object sender, EventArgs e)
  {
    TxObjectList selectedObjects = this.m_operations_txObjGridCtrl.SelectedObjects;
    TxObjectList txObjectList = this.ListOfSelectedObjectsOrdered();
    for (int index = ((Collection<ITxObject>) txObjectList).Count - 1; index >= 0; --index)
    {
      int row1 = ((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects).IndexOf(((Collection<ITxObject>) txObjectList)[index]);
      if (row1 < this.m_operations_txObjGridCtrl.Count - 1)
        this.SwapRows(row1, row1 + 1);
    }
    this.m_operations_txObjGridCtrl.SetCurrentCell(((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects).IndexOf(((Collection<ITxObject>) selectedObjects)[0]), 0);
    this.m_operations_txObjGridCtrl.SelectedObjects = new TxObjectList(selectedObjects);
  }

  private TxObjectList ListOfSelectedObjectsOrdered()
  {
    TxObjectList txObjectList = new TxObjectList();
    foreach (ITxObject itxObject in (Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)
    {
      if (((Collection<ITxObject>) this.m_operations_txObjGridCtrl.SelectedObjects).Contains(itxObject))
        ((Collection<ITxObject>) txObjectList).Add(itxObject);
    }
    return txObjectList;
  }

  private void SwapRows(int row1, int row2)
  {
    ITxObject itxObject1 = this.m_operations_txObjGridCtrl.GetObject(row1);
    ITxObject itxObject2 = this.m_operations_txObjGridCtrl.GetObject(row2);
    if (itxObject1 == null || itxObject2 == null)
      return;
    this.m_operations_txObjGridCtrl.EnableRecurringObjects = true;
    this.m_operations_txObjGridCtrl.SetObject(row1, itxObject2);
    this.m_operations_txObjGridCtrl.SetObject(row2, itxObject1);
    this.m_operations_txObjGridCtrl.EnableRecurringObjects = false;
  }

  private void m_operations_txObjGridCtrl_SelectionChanged(
    object sender,
    TxObjGridCtrl_SelectionChangedEventArgs args)
  {
    this.RefreshUpDownButtonsStatus();
  }

  private void RefreshUpDownButtonsStatus()
  {
    if (((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects).Count > 0 && ((Collection<ITxObject>) this.m_operations_txObjGridCtrl.SelectedObjects).Count > 0)
    {
      if (((Collection<ITxObject>) this.m_operations_txObjGridCtrl.SelectedObjects).Contains(((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)[0]))
        ((Control) this.m_up_button).Enabled = false;
      else
        ((Control) this.m_up_button).Enabled = true;
      if (((Collection<ITxObject>) this.m_operations_txObjGridCtrl.SelectedObjects).Contains(((Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)[this.m_operations_txObjGridCtrl.Count - 1]))
        ((Control) this.m_down_button).Enabled = false;
      else
        ((Control) this.m_down_button).Enabled = true;
    }
    else
    {
      ((Control) this.m_up_button).Enabled = false;
      ((Control) this.m_down_button).Enabled = false;
    }
  }

  private void m_operations_txObjGridCtrl_RowDeleted(
    object sender,
    TxObjGridCtrl_RowDeletedEventArgs args)
  {
    this.enableCreateIfValid();
  }

  private void SimulationPlayer_SimulationEndedForward(
    object sender,
    TxSimulationPlayer_SimulationEndedForwardEventArgs args)
  {
    this.enableCreateIfValid();
    this.handleRootObjectsDeletedDuringSimulation();
  }

  private void SimulationPlayer_SimulationEndedBackward(
    object sender,
    TxSimulationPlayer_SimulationEndedBackwardEventArgs args)
  {
    this.enableCreateIfValid();
    this.handleRootObjectsDeletedDuringSimulation();
  }

  private void SimulationPlayer_SimulationStartedBackward(
    object sender,
    TxSimulationPlayer_SimulationStartedBackwardEventArgs args)
  {
    this.enableCreateIfValid();
  }

  private void SimulationPlayer_SimulationStartedForward(
    object sender,
    TxSimulationPlayer_SimulationStartedForwardEventArgs args)
  {
    this.enableCreateIfValid();
  }

  private void SimulationPlayer_SimulationStopped(
    object sender,
    TxSimulationPlayer_SimulationStoppedEventArgs args)
  {
    this.enableCreateIfValid();
    this.handleRootObjectsDeletedDuringSimulation();
  }

  private void m_application_SimulationInitialized(object sender, EventArgs e)
  {
    if (this.m_simulationSnapshotData != null)
      return;
    this.createSimulationSnapshot();
  }

  private void createSimulationSnapshot()
  {
    this.m_simulationSnapshotData = new TxPhysicalRootEx().CreateSimulationSnapshot();
  }

  private void applySimulationSnapshot()
  {
    if (this.m_simulationSnapshotData == null)
      return;
    new TxPhysicalRootEx().ApplySimulationSnapshot(this.m_simulationSnapshotData);
  }

  private void registerForRootObjectEvents(ITxSweptVolumeHoldingObject gridObj)
  {
    if (TxEngineeringDataInternal.GlobalGetPartsMode() != 2 || !(gridObj is TxObjectFlowOperation))
      return;
    ITxLocatableObject rootObject = CApSVUtilities.getRootObject(gridObj);
    if (rootObject == null || !(rootObject is ITxPartAppearance) || this.m_gridObjIdToRegRootObjectMap != null && this.m_gridObjIdToRegRootObjectMap.ContainsKey(((ITxObject) gridObj).Id))
      return;
    if (this.m_gridObjIdToRegRootObjectMap == null)
      this.m_gridObjIdToRegRootObjectMap = new Dictionary<string, ITxLocatableObject>();
    this.m_gridObjIdToRegRootObjectMap.Add(((ITxObject) gridObj).Id, rootObject);
    ((ITxObject) rootObject).Deleted += new TxObject_DeletedEventHandler(this.rootObj_Deleted);
  }

  private void unregisterForRootObjectEvents(ITxSweptVolumeHoldingObject gridObj)
  {
    if (this.m_gridObjIdToRegRootObjectMap == null || !this.m_gridObjIdToRegRootObjectMap.ContainsKey(((ITxObject) gridObj).Id))
      return;
    ITxLocatableObject idToRegRootObject = this.m_gridObjIdToRegRootObjectMap[((ITxObject) gridObj).Id];
    this.m_gridObjIdToRegRootObjectMap.Remove(((ITxObject) gridObj).Id);
    ((ITxObject) idToRegRootObject).Deleted -= new TxObject_DeletedEventHandler(this.rootObj_Deleted);
  }

  private bool isRegisteredForRootObjectEvents(ITxSweptVolumeHoldingObject gridObj)
  {
    bool flag = false;
    if (this.m_gridObjIdToRegRootObjectMap != null && this.m_gridObjIdToRegRootObjectMap.ContainsKey(((ITxObject) gridObj).Id))
      flag = true;
    return flag;
  }

  private void registerForRootObjectEvents()
  {
    foreach (ITxObject gridObj in (Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)
    {
      if (gridObj is ITxSweptVolumeHoldingObject)
        this.registerForRootObjectEvents(gridObj as ITxSweptVolumeHoldingObject);
    }
  }

  private void unregisterForRootObjectEvents()
  {
    foreach (ITxObject gridObj in (Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)
    {
      if (gridObj is ITxSweptVolumeHoldingObject)
        this.unregisterForRootObjectEvents(gridObj as ITxSweptVolumeHoldingObject);
    }
  }

  private void rootObj_Deleted(object sender, TxObject_DeletedEventArgs args)
  {
    if (this.m_gridObjIdToRegRootObjectMap == null)
      return;
    List<ITxSweptVolumeHoldingObject> collection = new List<ITxSweptVolumeHoldingObject>();
    Dictionary<string, ITxLocatableObject>.Enumerator enumerator = this.m_gridObjIdToRegRootObjectMap.GetEnumerator();
    while (enumerator.MoveNext())
    {
      KeyValuePair<string, ITxLocatableObject> current = enumerator.Current;
      if (current.Value == sender)
      {
        foreach (ITxObject itxObject in (Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)
        {
          if (itxObject is ITxSweptVolumeHoldingObject)
          {
            string id = itxObject.Id;
            current = enumerator.Current;
            string key = current.Key;
            if (id == key)
              collection.Add(itxObject as ITxSweptVolumeHoldingObject);
          }
        }
      }
    }
    if (collection.Count == 0)
      return;
    foreach (ITxSweptVolumeHoldingObject gridObj in collection)
      this.unregisterForRootObjectEvents(gridObj);
    if (this.m_createOrStopMode)
    {
      if (this.m_application == null || !collection.Contains(this.m_application.SVHoldingObject))
        return;
      int num = (int) this.reportError(EApSweptVolumeErrorType.SV_MISSING_OPERATION_SIMULATED_OBJECT_DURING_CREATE, (object) this.m_application.SVHoldingObject);
      this.m_shouldStop = true;
      this.abortSweptVolumeCreation();
    }
    else
    {
      if (this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation == null)
        this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation = new List<ITxSweptVolumeHoldingObject>();
      this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation.AddRange((IEnumerable<ITxSweptVolumeHoldingObject>) collection);
    }
  }

  private void handleRootObjectsDeletedDuringSimulation()
  {
    if (this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation == null || this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation.Count <= 0)
      return;
    List<ITxSweptVolumeHoldingObject> volumeHoldingObjectList = new List<ITxSweptVolumeHoldingObject>();
    List<int> intList = new List<int>();
    int num1 = 0;
    foreach (ITxObject itxObject in (Collection<ITxObject>) this.m_operations_txObjGridCtrl.Objects)
    {
      if (itxObject is ITxSweptVolumeHoldingObject volumeHoldingObject && this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation.Contains(volumeHoldingObject))
      {
        if (CApSVUtilities.getRootObject(volumeHoldingObject) != null)
        {
          if (!this.isRegisteredForRootObjectEvents(volumeHoldingObject))
            this.registerForRootObjectEvents(volumeHoldingObject);
        }
        else
        {
          volumeHoldingObjectList.Add(volumeHoldingObject);
          intList.Add(num1);
        }
      }
      ++num1;
    }
    this.m_gridObjectsWithRootsObjectsDeletedDuringSimulation = (List<ITxSweptVolumeHoldingObject>) null;
    if (volumeHoldingObjectList.Count == 0)
      return;
    object[] objArray = new object[volumeHoldingObjectList.Count];
    for (int index = 0; index < volumeHoldingObjectList.Count; ++index)
      objArray[index] = (object) volumeHoldingObjectList[index];
    int num2 = (int) this.reportError(EApSweptVolumeErrorType.SV_MISSING_OPERATION_SIMULATED_OBJECT_BEFORE_CREATE, objArray);
    for (int index = intList.Count - 1; index >= 0; --index)
      this.m_operations_txObjGridCtrl.DeleteRow(intList[index]);
    if (this.m_operations_txObjGridCtrl.Count > 1)
    {
      ((Control) this.m_down_button).Enabled = true;
      ((Control) this.m_up_button).Enabled = true;
    }
    else
    {
      ((Control) this.m_down_button).Enabled = false;
      ((Control) this.m_up_button).Enabled = false;
    }
    this.enableCreateIfValid();
  }

  private void m_checkBox_IncludeCable_CheckedChanged(object sender, EventArgs e)
  {
  }
}
